package cn.iocoder.yudao.module.promotion.redpacket.service.admin;

import cn.iocoder.yudao.framework.business.basic.dao.query.CoreQueryWrapper;
import cn.iocoder.yudao.framework.business.basic.service.CrudService;
import cn.iocoder.yudao.framework.business.basic.service.impl.BaseService;
import cn.iocoder.yudao.module.promotion.redpacket.convert.RedPacketActivityConvert;
import cn.iocoder.yudao.module.promotion.redpacket.dao.RedPacketActivityMapper;
import cn.iocoder.yudao.module.promotion.redpacket.pojo.dto.RedPacketActivityQueryDTO;
import cn.iocoder.yudao.module.promotion.redpacket.pojo.dto.RedPacketActivitySaveDTO;
import cn.iocoder.yudao.module.promotion.redpacket.pojo.po.RedPacketActivity;
import cn.iocoder.yudao.module.promotion.redpacket.pojo.vo.RedPacketActivityVO;
import jakarta.annotation.Nonnull;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

/**
 * <pre>
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * 服务
 * OOoO0OOoO0OOOooo0oOOOO0OOOOO0oooOO0ooOOO0Ooooo0OOOOo0ooooO0OOooo0Ooooo0OOOOO
 * </pre>
 *
 * @author 山野羡民（1032694760@qq.com）
 * @since 2025/06/21
 */
@Service
public class RedPacketActivityService extends BaseService<RedPacketActivity, RedPacketActivityVO, RedPacketActivityQueryDTO> implements CrudService<RedPacketActivity, RedPacketActivityVO, RedPacketActivitySaveDTO, RedPacketActivityQueryDTO> {
    @Resource
    private RedPacketActivityMapper redPacketActivityMapper;

    @Override
    public RedPacketActivityMapper getInjectedMapper() {
        return redPacketActivityMapper;
    }


    @Nonnull
    @Override
    protected CoreQueryWrapper<RedPacketActivity> buildQueryWrapper(RedPacketActivityQueryDTO param) {
        CoreQueryWrapper<RedPacketActivity> wrapper = super.buildQueryWrapper(param);
        wrapper.eqIfPresent("shop_id", param.getShopId());
        wrapper.eqIfPresent("type", param.getType());
        return wrapper;
    }

    @Override
    public RedPacketActivity convertToEntity(RedPacketActivitySaveDTO param) {
        return RedPacketActivityConvert.INSTANCE.toEntity(param);
    }

}
